package com.mengfou.linklist;

public class Node{
    int val;
    Node next;
    public Node(int val){
        this.val = val;
    }

    public static Node createLinkedList(int[] arr){
        if(arr == null || arr.length == 0) return null;
        Node dummyNode = new Node(-1);
        Node ptr = dummyNode;
        for (int val : arr) {
            ptr.next = new Node(val);
            ptr = ptr.next;
        }
        ptr.next = null;
        return dummyNode.next;
    }

    public static void printLinkedList(Node head){
        Node ptr = head;
        while(ptr != null){
            System.out.print(ptr.val+"\t");
            ptr = ptr.next;
        }
        System.out.println();
    }
}
